﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ServiceStack.Redis;
using ServiceStack.Redis.Generic;
using System.Linq.Expressions;

namespace DataCollectService
{
    public interface IRepository<TEntity> where TEntity : Entity
    {

        #region 公共方法

        /// <summary>
        ///     插入实体记录
        /// </summary>
        /// <param name="entity"> 实体对象 </param>
        /// <returns> 操作影响的行数 </returns>
        TEntity Insert(TEntity entity,DateTime expireTime);
        /// <summary>
        /// 更新实体记录
        /// </summary>
        /// <param name="entity"></param>
        void Update(TEntity entity,DateTime expireTime);
        /// <summary>
        /// 根据Id获取单个实体记录
        /// </summary>
        /// <param name="Id">Id</param>
        /// <returns>实体记录</returns>
        TEntity GetById(object Id);

        /// <summary>
        /// 查询列表
        /// </summary>
        /// <param name="predicate">谓语表达式</param>
        /// <returns></returns>
        IList<TEntity> GetList(Func<TEntity, bool> predicate);

        #endregion
    }
}
